# Maintainer: Mateusz Mikuła <mati865@gmail.com>
# Contributor: Renato Silva <br.renatosilva@gmail.com>

pkgname=ccache
pkgver=3.7.5
pkgrel=1
pkgdesc="A compiler cache (mingw-w64)"
arch=('i686' 'x86_64')
url="https://ccache.samba.org/"
license=("GPL3")
replaces=("${pkgname}-git")
makedepends=("gcc" "pkg-config" "zlib-devel")
depends=("gcc-libs" "zlib")
options=('staticlibs' 'strip')
install="${pkgname}.install"
source=(https://github.com/ccache/ccache/releases/download/v${pkgver}/ccache-${pkgver}.tar.xz{,.asc}
        "ccache-3.4.2-msys.patch")
validpgpkeys=("5A939A71A46792CF57866A51996DDA075594ADB8") #Joel Rosdahl <joel@rosdahl.net>
sha256sums=('e51c611a3da865754cb0ff1ddd95bd7a6acac603576c0bd39583f8cc30af28d2'
            'SKIP'
            '061d553a59960c87ccacaf26130cf59eb56017c25742853b6da91093eaf1f58d')

prepare() {
  cd ${pkgname}-${pkgver}

  patch -p1 -i ${srcdir}/ccache-3.4.2-msys.patch
}

build() {
  [[ -d build-${CHOST} ]] && rm -rf build-${CHOST}
  mkdir -p build-${CHOST}  && cd build-${CHOST}
  ../${pkgname}-${pkgver}/configure \
      --prefix=/usr \
      --build=${CHOST} \
      --host=${CHOST} \
      --target=${CHOST}
  make
}

check() {
  cd "${srcdir}/build-${CHOST}"

  make check
}

package() {
  cd "${srcdir}/build-${CHOST}"
  make DESTDIR="${pkgdir}" install
}
